﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="YoProgramo.Infrastructure.Tools.PagedList"%>
<%@ Import Namespace="YoProgramo.Domain.BusinessLogic.Service"%>
<%@ Import Namespace="YoProgramo.Domain.BusinessLogic.Extensions"%>
<%@ Import Namespace="YoProgramo.Domain.Core.Interfaces"%>
<%@ Import Namespace="YoProgramo.BusinessLogic.Service"%>
<%@ Import Namespace="Microsoft.Practices.ServiceLocation"%>

    <%
      var serviceComment = ServiceLocator.Current.GetInstance<ICommentService>();
      var s = (IPagedList<IStory>)ViewData.Model;                       
    %>
       
    <div class="storyList">          
      <%foreach (IStory story in s) { 
          %>    
        <div class="storyRow">
        <div class="ranks">
          <div class="RankBoxvot">
            <div id="storyRank-<%= story.Id %>" class="storyRank"><%= story.GetScore() %>        
            </div>                  
            <div class="textInRankBox">
              Votos
            </div>                       
          </div>
          <div class="RankBoxvot">
            <div class="storyRank"><%= serviceComment.GetCleanComments(story.Comments).Count %>         
            </div>
           <div class="textInRankBox storyRankAnswers">
              Resp.
            </div>                               
          </div>

          <div class="RankBoxvot">
            <div class="storyRank"><%= story.GetVisitsCount() %>         
            </div>
           <div class="textInRankBox">
              Visitas
            </div>                               
          </div>                   
        </div>
                             
          <div class="storyText">  
            <div class="storyTitle"><h2><%= Html.RouteLink(story.Title, "StoryView", new { slug = story.Slug })%></h2></div>
            <div class="storyResume"> <%
              if (story.Category != null)
              {
                %>
                
                 <%= Html.RouteLink(story.Category.Name, "ViewItems", new RouteValueDictionary(new { slug = story.Category.Slug }), null)%>                 
                
                <%
              }
              if (story.Tags != null)
              {
                %>                
                <%
                foreach(ITag t in story.Tags)
                {
                %>
                  <%= Html.RouteLink(t.Name, "ViewTagItems", new RouteValueDictionary(new { slug = t.Slug }), null)%>                  
                <%
                }
                %>
                
                <%
              }
%><br />            
<%= story.PostedAt%> | <b>Por:</b> <%= Html.RouteLink(story.ByUser.UserName, "Default", new { action = "ViewProfile", controller = "User", id = story.ByUser.Id })%>
            </div>          
          </div>
        </div>                       
        <%} %>               
    </div>        
    
    <%= Html.Paging<IStory>(s, ViewData["UrlPaging"] as string, "__PAGENUM__")%>

